﻿using System.Globalization;
using System.Linq;
using Medianamik.Core;
using Medianamik.Core.DAL;
using Medianamik.Core.DAL.Repositories;
using Medianamik.Core.DAL.Services;
using SubSonic;

namespace Medianamik.UI.Web.Shop.Data.Repositories
{
 

    public class PostCanadaRepository<TCollection,T> :MedianamikRepository<TCollection,T>,
        IPostCanadaRepository<T>
        where T : IPostCanada, IRecordBase, new()
        where TCollection : ICollectionWithChildren<TCollection, T>, new()
    {
        public PostCanadaRepository(ICultureService cultureService, IContentStateService contentStateService, INodeMapper nodeMapper) : base(cultureService, contentStateService, nodeMapper)
        {
        }

        public T Get()
        {
            return All(CultureInfo.InvariantCulture, ContentState.Draft,
                ActiveStatus.Activated).FirstOrDefault();
        }
    }

    public class PostCanadaRepository : MedianamikRepository<PostCanadaCollection,
                                            PostCanada>, IPostCanadaRepository
    {
        public PostCanadaRepository(ICultureService cultureService, IContentStateService contentStateService, INodeMapper nodeMapper)
            : base(cultureService, contentStateService, nodeMapper)
        {
        }

        public PostCanada Get()
        {
            return All(CultureInfo.InvariantCulture, ContentState.Draft,
                ActiveStatus.Activated).FirstOrDefault();
        }
    }

    public interface IPostCanadaRepository<T> : IMedianamikRepository<T>
     where T : IPostCanada
    {
        T Get();
    }


    public interface IPostCanadaRepository : IPostCanadaRepository<PostCanada>
    {

    }
}
